// Setup pins driving segments
int a = 7, b = 6, c = 5, d = 4, e = 3, f = 2, g = 1;
int pins[8] = {a, b, c, d, e, f, g};
int at = 0;

// number segment sequences
int zero[6] = {a, b, c, d, e, f};
int one[2] = {b, c};
int two[5] = {a, b, g, e, d};
int three[5] = {a, b, g, c, d};
int four[4] = {f, g, b, c};
int five[5] = {a, f, g, c, d};
int six[5] = {f, e, d, c, g};
int seven[3] = {a, b, c};
int eight[7] = {a, b, c, d, e, f, g};
int nine[5] = {f, a, b, g, c};

int i;


void clear()
{
  for (int i=0;i<=7;i++)
  {
    digitalWrite(pins[i], LOW);
  }
}

void drawNumber(int num)
{
  
  clear();
  
  switch (num)
  {
    
    case 0:
      for (i=0;i<6;i++) { digitalWrite(zero[i], HIGH); }
      break;
      
    case 1:
      for (i=0;i<2;i++) { digitalWrite(one[i], HIGH); }
      break;
      
    case 2:
      for (i=0;i<5;i++) { digitalWrite(two[i], HIGH); }
      break;
      
    case 3:
      for (i=0;i<5;i++) { digitalWrite(three[i], HIGH); }
      break;
      
    case 4:
      for (i=0;i<4;i++) { digitalWrite(four[i], HIGH); }
      break;
      
    case 5:
      for (i=0;i<5;i++) { digitalWrite(five[i], HIGH); }
      break;
      
    case 6:
      for (i=0;i<5;i++) { digitalWrite(six[i], HIGH); }
      break;
      
    case 7:
      for (i=0;i<3;i++) { digitalWrite(seven[i], HIGH); }
      break;
      
    case 8:
      for (i=0;i<7;i++) { digitalWrite(eight[i], HIGH); }
      break;
      
    case 9:
      for (i=0;i<5;i++) { digitalWrite(nine[i], HIGH); }
      break;
      
  }
  
}

void setup()
{
  for (int i=0; i<=7;i++)
  {
    Serial.println("set pin mode");
    pinMode(pins[i], OUTPUT);
  }
  
}

void loop()
{
  
  drawNumber(at);
  delay(1000);
  
  if (at == 9)
    at = 0
  else
    at++;
  
}
